<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');
Route::get('/callback', function (Request $request) {
    $http = new GuzzleHttp\Client;

    $response = $http->post('http://www.haokanxs.xyz/oauth/token', [
        'form_params' => [
            'grant_type' => 'password',
            'client_id' => '5',
            'client_secret' => 'hDBT6zm8WP4oUJpPMdsXCtHkCVPNYjMkMua99n8u',
            'redirect_uri' => 'http://www.haokanxs.xyz/callback',
            'username' => 'admin@olcms.com',
		'password'=>'123456'
        ],
    ]);

    return json_decode((string) $response->getBody(), true);
});
Route::get("/tester/index",'TesterController@index')->middleware('auth:api');
Route::get('/clwzcx/verifycode',function(){
    header ("content-Type: text/html; charset=utf-8");
    $cookie_file = resource_path('tmp').'/cookie.txt';

    //这是验证码地址
    $verify_code_url = "http://xmitcc.xmjj.gov.cn/jtwf/ClinicCountManager/captcha-image.do";

    $curl = curl_init ();
    curl_setopt ($curl,CURLOPT_URL,$verify_code_url );
    curl_setopt ($curl,CURLOPT_COOKIEJAR,$cookie_file );
    curl_setopt ($curl, CURLOPT_HEADER,false );
    $header = [
            'Referer'=>'http://www.xmjj.gov.cn/xxfw/shouye.action',
            'User-Agent'=>'User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36'
    ];
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    curl_setopt ($curl,CURLOPT_RETURNTRANSFER,true );
    $img = curl_exec ($curl );
    curl_close ($curl );

    //保存验证码
    return $img;
});

